from PyQt5.QtCore import Qt

from bin.ini import Ini


class Action:

    def __init__(self):
        self.autoLogin = None
        self.show = None

    def checkBoxLogin(self, state):
        """自动登录勾选框"""
        if state == Qt.Checked:
            self.autoLogin = '1'
        else:
            self.autoLogin = '0'

    def checkBoxSave(self, state):
        """记住密码勾选框"""
        if state == Qt.Checked:
            self.show = '1'
        else:
            self.show = '0'

    # def pushButtonSetup(self):
    #     print(self.show)
    #     print('点击配置按钮')

    def pushButtonLogin(self):
        # 判断config.ini是否需要修改
        ini = Ini()
        if self.autoLogin is not None:
            ini.set('Login', 'autoLogin', self.autoLogin)
        if self.show is not None:
            ini.set(section='Login', key='show', value=self.show)
        # 执行登录操作
